import React from "react";
import { Route, Redirect,useLocation} from "react-router-dom";
import ContentRouterConfig from "./ContentRouterConfig";
const ContentRouter = () =>{
   const location = useLocation();
   const pathname = location.pathname;
   const currentContentRouter = ContentRouterConfig.find((item,i)=>{
      return item.path === pathname
   }) 

   if(!currentContentRouter){
      return <Redirect exact to="/404" />;
   }else{
      return <Route exact path={pathname} component={currentContentRouter.component} />
   }
 
}

export default ContentRouter